<!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <title>调试界面-同时发送ws和http</title>
 </head>
 <body>
 <div id="chat_room">
     <p>请输入控制参数内容(/agv/ctrl?cmd=)：<input type="text" id="msg">
         <button id="send" onclick="send()">发送</button>
     </p>
     <div id="chat_content"></div>
 </div>
 </body>
 <script type="application/javascript">
     var ws = new WebSocket('ws://{{ ip }}/makeSocket/test');
     ws.onmessage = function (MessageEvent) {
         console.log(MessageEvent);
         console.log(MessageEvent.data);
         var time=new Date();
         var t= time.toLocaleString();
         var p=document.createElement("p");
         p.innerText="("+t+")"+MessageEvent.data;
         document.getElementById('chat_content').appendChild(p);
     };
 
     function send() {
         var msg = document.getElementById('msg').value;
         ws.send(msg);
		 httpRequest.open('GET', '/agv/ctrl?cmd='+msg, true);//第二步：打开连接  将请求参数写在url中  ps:"./Ptest.php?name=test&nameone=testone"
httpRequest.send();//第三步：发送请求  将请求参数写在URL中

     }
 
 var httpRequest = new XMLHttpRequest();//第一步：建立所需的对象

httpRequest.onreadystatechange = function () {
  if (httpRequest.readyState == 4 && httpRequest.status == 200) {
    var json = httpRequest.responseText;//获取到json字符串，还需解析
    console.log(json);
  }
};
 </script>
 </html>
